#ifndef _MSG_FILTER_H
#define _MSG_FILTER_H

#include "portable.h"
#include "netfilter.h"
#include <string>

enum EFilterType
{
  EFT_PRE,
  EFT_LOGIN,
  EFT_MAX,
};

typedef void (*msgfunc)(Client*,const NetPacket&);

class MsgFilterBase:public INetFilter
{
public:
  explicit MsgFilterBase(EFilterType et);
  bool regmsgfunc(uint16 m,msgfunc f);
  virtual void OnRecvNetPacket(Client* client,const NetPacket& recvPack);
  EFilterType type(){return eftype;}
private:
  EFilterType eftype;
  msgfunc functbl[MAXWORD];
};

class MsgFilterPre:public MsgFilterBase
{
  typedef MsgFilterBase base;
public:
  MsgFilterPre(EFilterType et):base(et){name="MsgFilterPre";}
private:
  std::string name;
};

class MsgFilterNormal:public MsgFilterBase
{
  typedef MsgFilterBase base;
public:
  MsgFilterNormal(EFilterType et):base(et){name="MsgFilterNormal";}
private:
  std::string name;
};

class MsgFilterManager:public NetFilterManager
{
public:
  ~MsgFilterManager();
  MsgFilterManager();
  virtual INetFilter* CreateFilter(int id);
  void Release();
private:
  INetFilter* _filter[EFT_MAX];
};
#endif